/*
 * Copyright (C) 2013 The i18nCTS Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.googlecode.i18nCTS.view;

import java.util.Calendar;
import java.util.Locale;

import android.annotation.SuppressLint;
import android.util.Log;

import com.googlecode.i18nCTS.provider.i18nCTSProvider;

public class StringSectionFragment extends AbstractSectionFragment {
	private static final String TAG = "I18nCTS_" + StringSectionFragment.class.getSimpleName();
	public static final String CATEGORY = "String";

	public StringSectionFragment() {
		Log.d(TAG, "ctr");
	}
	
	public String getCategory() {
		return CATEGORY;
	}
	
	@SuppressLint("DefaultLocale")
	public void buildList(i18nCTSProvider provider) {
		Calendar calendar;
		
		//GregorianCalendar
		calendar = Calendar.getInstance(Locale.getDefault());
		calendar.set(2012, 12, 5, 0, 0); 
		calendar.add(Calendar.DAY_OF_MONTH, calendar.getFirstDayOfWeek());
			
	    // ===================== Month names ===========================================
		String month_names = "";
		String abbrv_month_names = "";		
	    for (int i = 0; i < 12; i++) {
	    	calendar.set(Calendar.MONTH, i);
	    	month_names += String.format("%tB ", calendar);
	    	abbrv_month_names += String.format("%tb ", calendar);
	    }
	    provider.addData(month_names.trim(), "String.format(\"%tB\") Full Month names");
	    provider.addData(abbrv_month_names.trim(), "String.format(\"%tb\") Abb Month names");
	        
	    // ===================== Weekday names ==============================================
		String weekday_names = "";
		String abbrv_weekday_names = "";
	    calendar.set(Calendar.MONTH, 11); 
	    for (int i = 9; i < 16; i++) {
		    calendar.set(Calendar.DATE, i); // Dec 9 2012 is Sunday
		    weekday_names += String.format("%tA ", calendar);
		    abbrv_weekday_names += String.format("%ta ", calendar);
	    }
	    provider.addData(weekday_names.trim(), "String.format(\"%tA\") Full Weekday names");
	    provider.addData(abbrv_weekday_names.trim(), "String.format(\"%ta\") Abbrev. Weekday names");	   
	    
	    // reset Calendar
	    calendar.set(2012, 1, 3, 4, 7, 3); // set 2012 feb 3rd, 4th hour of day, 7 min

	    provider.addData(String.format("%tc",  calendar), "String.format(\"%tc\") Locale-preferred date and time");
	    provider.addData(String.format("%tF",  calendar), "String.format(\"%tF\") Full date in ISO 8601 format (YYYY-MM-DD)");
	    provider.addData(String.format("%tr",  calendar), "String.format(\"%tr\") Full 12-hour time");
	    provider.addData(String.format("%tR",  calendar), "String.format(\"%tR\") Short 24-hour time");
	    provider.addData(String.format("%tT",  calendar), "String.format(\"%tT\") Full 24-hour time");
	    provider.addData(String.format("%tZ",  calendar), "String.format(\"%tZ\") Localized time zone abbreviation");
	    
	    provider.addTitle(CATEGORY);	    
	}
}